In disk drives such as magnetic, optical and magneto-optical disk drives, there are commands that require the hard disk controller (HDC) to compute a bit by bit XOR of two data sources and save the result for purposes of computing redundant information for a RAID system. This typically involves reading the operands from and writing the result back to the system memory. When the system memory is a DRAM, it is more efficient to read and write data in bursts. A small buffer is used to hold the first data source while the second data source is read from the memory.
As shown in FIG. 7, the size of a basic data unit or sector 200 in a disk drive is typically larger than the individual data segments 202 that make up the sector. When transferring the sector 200, individual segments are transferred separately beginning with a first segment 204 and ending with the last segment 206. Each segment 202 is transferred to or from a system memory in a single memory operation. The data sector 200 also includes a cyclic redundancy check (CRC) value 208 contained in the final data segment 206 as the final data in the segment. The CRC value 208 is used to detect data corruption that may have occurred in the sector 200.
An example of a known process for performing an exclusive or logical (XOR) operation on two data sectors is shown in FIG. 8. The process starts by fetching a segment of the first data sector or operand 1 from source address 1 in the memory in which the data sector is stored (Block 300). A CRC (Block 302) and a parity (Block 304) for the segment are calculated. The segment and the parity are then written to a buffer (Block 306).
On the last segment 206 of operand 1 (Block 308), the calculated CRC value of the segment is compared against the CRC value 208 of operand 1 (i.e., the CRC value stored in the last segment of the sector 200) to check for a CRC error (Block 310). If an error is detected (Block 312), the main control processor of the disk drive is notified (Block 314) and the process comes to a halt. If no error is detected (Block 312), a parity is calculated for the last segment 206 of operand 1 (Block 304) and stored in the buffer along with the last segment (Block 306).
Each time a segment and a corresponding parity of operand 1 is written in the buffer, a corresponding segment from the second data sector or operand 2 is fetched from source address 2 in the memory (Block 316), and the CRC for this segment is calculated in the same way as for the segments in operand 1 (Block 318). The segment of operand 1 and the corresponding parity stored in the buffer are read and the parity is checked (Block 320). If no parity error is detected, the XOR of the segment of operand 1 and the corresponding segment of operand 2 is computed (Block 322), and the parity of the XOR result is calculated (Block 324). The result of the XOR operation and the parity is then written to the XOR buffer (Block 326).
The result of the XOR operation stored in the XOR buffer is then read, the parity is checked and the CRC is computed for the XOR result (Block 328) if no parity error is detected. On the last segment (Block 330), the XOR results and the CRC are written to the memory at the destination address of the memory (Block 332). On all segments prior to the last, the XOR result is written to the memory at the destination address of the memory (Block 334) and the source and destination address pointers are advanced by the segment size (Block 336).
As described above, a parity is used to detect data corruption that occurs in the XOR buffer in a known XOR operation. This requires making the XOR buffer 1 bit wider than the size the data to hold the parity bit, resulting in the XOR buffer being larger and more expensive.